/**
 * 
 */
package org.jackysoft.entity;




import org.jackysoft.bean.define.EntitySchemas;
import org.jackysoft.entity.base.AbstractEntity;

/**
 * @author qujiakang
 * 
 */


public class Department extends AbstractEntity implements
		Comparable<Department> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5852801939166078336L;

	public static final Department NONE = new Department();

	private String name;

	private String parent;

	private int dType;

	private int level = -1;
	
	private int enabled = 1;
	
	public Department() {
		super();
		this.setName("");
	}

	public Department(String id) {
		this.id = id;
	}

	public Department(String id, String name) {
		this.id = id;
		this.name = name;
	}

	public Department(String id, String name, String parent,
			int dtype) {
		this(id, name);
		this.parent = parent;
		this.dType = dtype;
	}

	/**
	 * @return name
	 */

	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            要设置的 name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/*
	 * （非 Javadoc）
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof Department))
			return false;
		Department dept = (Department) obj;
		if (dept.getId() == null)
			return false;
		return dept.getId().equals(this.id);

	}

	
	
	@Override
	public int compareTo(Department o) {
		return this.sort - o.sort;
	}

	public boolean sameAs(Department d) {
		if (d == null || d.id == null || this.id == null)
			return false;
		return this.id.equals(d.id);
	}

	@Override
	public String toString() {
		return name + "[" + id + "]";
	}
		
	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public String getParent() {
		return parent;
	}

	public void setParent(String parent) {
		this.parent = parent;
	}

	public int getdType() {
		return dType;
	}

	public void setdType(int dType) {
		this.dType = dType;
	}

	public int getEnabled() {
		return enabled;
	}

	public void setEnabled(int enabled) {
		this.enabled = enabled;
	}	
	
	
	

}
